home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / L-M / MacGS Menu INIT ƒ / src / MacGS Menu INIT.c next >
Encoding:
C/C++ Source or Header  |  1993-04-20  |  846 b   |  56 lines  |  [TEXT/KAHL]

  1. #include <SetUpA4.h>
  2. #include <Traps.h>
  3.  
  4.  
  5. static pascal long (*saveMenuSelect) (Point startPt);
  6. static pascal long menuSelectPatch (Point startPt);
  7.  
  8.  
  9.     pascal void
  10. main (void)
  11.  
  12. {
  13.     Handle    h;
  14.  
  15.  
  16.     //    Make our INIT code persistent
  17.  
  18.     RememberA0 ();
  19.     SetUpA4 ();
  20.  
  21.     asm
  22.     {
  23.         dc.w    _RecoverHandle
  24.         move.l    A0, h
  25.     }
  26.     HLock (h);
  27.     DetachResource (h);
  28.  
  29.     //    Patch MenuChoice's code
  30.  
  31.     saveMenuSelect = (void *) NGetTrapAddress (_MenuSelect, ToolTrap);
  32.     NSetTrapAddress ((long) menuSelectPatch, _MenuSelect, ToolTrap);
  33.  
  34.     RestoreA4 ();
  35. }
  36.  
  37.  
  38.     static pascal long
  39. menuSelectPatch (Point startPt)
  40.  
  41. {
  42.     short    saveResFile;
  43.     long    retVal;
  44.  
  45.  
  46.     SetUpA4 ();
  47.  
  48.     saveResFile = CurResFile ();            //    save the current resource file
  49.     retVal = (*saveMenuSelect) (startPt);    //    do the old patch code
  50.     UseResFile (saveResFile);                //    restore the old value
  51.  
  52.     RestoreA4 ();
  53.  
  54.     return retVal;
  55. }
  56.